<template>
	<view class="home_chart">
		<view class="content">
			<view class="title">
				<text>近7日实时验券</text>
			</view>
			<view class="chart_wrap">
				<view class="chart">
					<qiun-data-charts type="line" :opts="opts" :chartData="chartData" />
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import { getChartData } from '@/request/api.js'
	export default {
		data() {
			return {
				opts: {
					color: ["#1890FF", "#91CB74"],
					padding: [15, 10, 0, 15],
					enableScroll: false,
					legend: {},
					xAxis: {
						disableGrid: true,
					},
					yAxis: {
						gridType: "dash",
						dashLength: 2
					},
					extra: {
						line: {
							type: "straight",
							width: 2,
							activeType: "hollow"
						}
					}
				},
				chartData: {
					categories: ["一", "二", "三", "四", "五", "六", "七"],
					series: [{
							name: "验券数量",
							data: [0, 0, 0, 0, 0, 0, 0]
						},
					]
				}
			};
		},
		onShow(){
			// this.getChartData();
		},
		created(){
			this.getChartData();
		},
		mounted() {},
		methods: {
			async getChartData(){
				let res = await getChartData();
				// this.chartData.categories = Object.values(res.data.times||["一", "二", "三", "四", "五", "六", "七"]);
				this.chartData.series[0].data = res.data.data;
				console.log(res.data)
			}
		},
	}
</script>

<style lang="scss" scoped>
	.content {
		background-color: #fff;
		border-radius: 14rpx;

		.title {
			padding: 40rpx 25rpx 25rpx;
			border-bottom: 1px solid $line-grey;
		}

		.chart_wrap {
			width: 100%;
			padding: 25rpx;
			box-sizing: border-box;

			.chart {
				// box-sizing: border-box;
				// background-color: #eee;
			}
		}
	}
</style>